package com.ladlee.parking.entity.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ladlee.parking.constant.ParkingEnum;
import com.ladlee.parking.validate.custom.EnumCheck;
import com.ladlee.parking.validate.group.Update;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.GroupSequence;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * 注解@GroupSequence指定分组校验的顺序，即先校验Save分组的，如果不通过就不会去做后面分组的校验了
 */
@Data
//@GroupSequence({Update.class,Save.class,...}) 会按照分组顺序，依次执行
public class ParkingVo implements Serializable {

    private static final long serialVersionUID = 4550814539815369713L;

    @NotNull(message = "ID不能为空", groups = Update.class)
    private Integer parkingId;

    private String parkingCode;

    private String parkingUser;

    private String parkingPhone;

    private String carNum;

    /**
     * 停车费金额
     */
    @NotBlank(message = "金额不能为空")
    private String parkingAmount;

    /**
     * 费用类型(0:临停车,1:月租车,2:年租车)
     */
    @EnumCheck(enumClass = ParkingEnum.class, message = "请选择:临停车,月租车,年租车", groups = Update.class)
    private Integer parkingType;

    private String parkingTypeName;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date parkingTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date parkingEnd;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

}
